# -*- coding: utf-8 -*-

import json

class TEasyJson:
    def __init__(self, target_date):
        if type(target_date) == dict:
            self.data = target_date
        else:
            with open(target_date, 'r', encoding = 'utf-8') as fdate:
                self.data = json.load(fdate)
        print(self.data)
        return

    def Dump(self, file_name: str, encoding = 'utf-8'):
        with open(file_name, 'w', encoding=encoding) as f:
            json.dump(self.data, f, indent=4)
        print(f"File '{file_name}' is successfully generated.\n")
        return self.data



if __name__ == "__main__":
    print("++++++++++++++++")
    sub={"subname":"rbl", "old":22}
    dict_data = {"name":"jpz", "old":26, "dictt":[1,2,3], "subdic":sub}
    dict_data = "../hopechart_template/hq_cfile_cfg.json"
    js = TEasyJson(dict_data)

    js.Dump("target.json")